<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('编辑学生记上课')"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-record-edit" >
        <input name="recordId" th:field="*{teachingStudentRecord.recordId}" type="hidden">
        <input name="studentConsume" th:field="*{teachingClasses.studentConsume}" type="hidden">
        <div class="form-group">
            <label class="col-sm-3 control-label">学生姓名：</label>
            <div class="col-sm-8">
                <input name="studentName" th:field="*{teachingStudentRecord.studentName}" class="form-control" type="text" disabled>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">班级名称：</label>
            <div class="col-sm-8">
                <input name="className" th:field="*{teachingStudentRecord.className}" class="form-control" type="text" disabled>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">消耗课时：</label>
            <div class="col-sm-2" style="width: 80px">
                <input name="lessonConsume" th:field="*{teachingStudentRecord.lessonConsume}" class="form-control" type="number" min="0">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">上课状态：</label>
<!--            <div th:name="attendStatus" class=" col-sm-8 btn-group">-->
<!--                <button class="btn btn-white" type="button" id="attend" value="0">到课</button>-->
<!--                <button class="btn btn-white" type="button" id="leave" value="1">请假</button>-->
<!--                <button class="btn btn-white" type="button" id="truant" value="2">旷课</button>-->
<!--            </div>-->
            <div class="col-sm-2" style="width: 100px">
                <select name="attendStatus" class="form-control" th:with="type=${@dict.getType('sys_attend_status')}" onchange="selectMe(this)">
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:field="*{teachingStudentRecord.attendStatus}" ></option>
                </select>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var prefix = ctx + "teaching/record";
    $("#form-record-edit").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/edit", $('#form-record-edit').serialize());
        }
    }

    function selectMe(obj){
        var initConsume = $("input[name ='studentConsume']").val();
        var iptConsume = $("input[name='lessonConsume']");
        if ($(obj).val() == 0) {
            iptConsume.val(initConsume);
        } else if ($(obj).val() == 1) {
            iptConsume.val(0);
        } else if ($(obj).val() == 2) {
            iptConsume.val(initConsume);
        }
    }

    // $("#attend").click(function (){
    //     document.getElementById("lessonConsume").value = "2";
    // })
    //
    // $("#leave").click(function (){
    //     document.getElementById("lessonConsume").value = "0";
    // })
    //
    // $("#truant").click(function (){
    //     document.getElementById("lessonConsume").value = "2";
    // })

</script>
</body>
</html>